<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
      <el-form-item prop="registerTime">
        <el-col :span="6">
          <el-form-item prop="scope">
            <el-select v-model="formInline.scope" placeholder="请选择范围">
              <el-option label="注册时间" :value="1"></el-option>
              <el-option label="申请时间" :value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="18">
          <el-form-item  prop="time">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-time="['00:00:00', '23:59:59']"
              value-format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item label="主账户余额">
        <el-col :span="11">
          <el-form-item prop="minBalance">
            <el-input v-model.trim="formInline.minBalance" placeholder="请输入" @keyup.enter.native="handleFilter"></el-input>
          </el-form-item>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-form-item prop="maxBalance">
            <el-input v-model.trim="formInline.maxBalance" placeholder="请输入" @keyup.enter.native="handleFilter"></el-input>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-form-item label="上分状态" prop="creditStatus">
        <el-select v-model="formInline.creditStatus" placeholder="请选择状态">
          <el-option
            v-for="item in consts.AGENCY_CREDIT_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择状态">
          <el-option
            v-for="item in consts.AGENCY_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
            v-if="![3,4].includes(item.value)"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item class="with-pre-select" prop="keywords">
        <el-input placeholder="请输入关键词" v-model.trim="formInline.keywords" class="input-with-select" @keyup.enter.native="handleFilter">
          <!--搜索类型：1账户名，2姓名，3IP，4上级代理-->
          <el-select v-model="formInline.searchType" slot="prepend" placeholder="请选择查询范围">
            <el-option label="账号名" :value="1"></el-option>
            <el-option label="姓名" :value="2"></el-option>
            <el-option label="银行卡" :value="3"></el-option>
            <el-option label="手机号" :value="4"></el-option>
            <el-option label="邮箱" :value="5"></el-option>
            <!-- <el-option label="IP（支持模糊搜索）" :value="6"></el-option> -->
            <el-option label="上级代理" :value="7"></el-option>
            <el-option label="备注" :value="8"></el-option>
          </el-select>
          <!--<el-button slot="append" icon="el-icon-search"></el-button>-->
        </el-input>
      </el-form-item>
      <el-form-item label="手续费方案(本月)" prop="feeRule">
        <el-select v-model="formInline.feeRule" placeholder="请选择手续费方案">
          <el-option
            v-for="item in commSeleList"
            :label="item.name"
            :key="item.id"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="佣金方案类型" prop="commMode">
        <el-select v-model="formInline.commMode" placeholder="请选择佣金方案类型">
          <el-option
            v-for="item in agencyEnum.COMMISSION_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="会员返佣方案" prop="cashRule">
        <el-select v-model="formInline.cashRule" placeholder="请选择会员返佣方案">
          <el-option
            v-for="item in commCaseSeleList"
            :label="item.name"
            :key="item.id"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
       <el-form-item label="玩家层级" prop="levelId">

        <el-select v-model="formInline.levelId" placeholder="请选择玩家层级">
          <el-option
            label="全部"
            :value="consts.ALL"
          ></el-option>
          <el-option
            v-for="item in levelList"
            :key="item.levelId"
            :label="item.name"
            :value="item.levelId"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="层级状态" prop="levelStatus">
        <el-select v-model="formInline.levelStatus" placeholder="请选择状态">
          <el-option
            v-for="item in consts.LEVEL_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-button
        class="filter-item"
        type="primary"
        :loading="loading"
        icon="el-icon-search"
        @click="handleFilter"
      >
        搜索
      </el-button>
      <el-button
        v-if="roleCheck('export-list')"
        type="primary"
        size="mini"
        icon="el-icon-download"
        @click="_exportExcel"
        :loading="downLoading"
      >
        导出
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>

// mixins
import { form, pickerOption, grid } from '@/build';
import { getUserLevelList } from '@/services/api/userLevel';
export default {
  name: 'form-filter',
  mixins: [form, pickerOption, grid],
  props: {
    downLoading: {
      type: Boolean,
      default: false,
    },
    commSeleList: {
      type: Array,
      default: () => [],
    },
    commCaseSeleList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      levelList: [],
      formInline: {
        userType: 1, // 0玩家，1代理
        time: [moment(consts.ONLINE_DATE).format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD 23:59:59')],
        minBalance: undefined,
        maxBalance: undefined,
        status: -1,
        creditStatus: undefined,
        searchType: 1,
        keywords: undefined,
        scope: 1,
        feeRule: -1,
        commMode: -1,
        cashRule: -1,
        levelId: -1,
      },
    };
  },
  methods: {
    _exportExcel() {
      this.$emit('on-export', this.formInline);
    },
    handleFilter() {
      this.$emit('submit-form', this.formInline);
    },
    selfResetForm(formname) {
      this.resetForm(formname);
      this.handleFilter();
    },
  },
  mounted() {

    this.bindGet(getUserLevelList, 'levelList', {
      sendingData:{'levelType':1}
    });
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 160px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
